﻿// Author : Le Khac Huy
// Group : 06TH1d.12
// Created : 12/5/2010
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data.Common;
using System.Data;
using System.Windows.Forms;
namespace QUANLYNHASACH.App_code.BLL
{

    public class DANGNHAP_BLL
    {
        public static bool layusername(string username)
        {
            bool ok = false;
            try
            {
                using (SqlConnection conn = new SqlConnection(QUANLYNHASACH.connect.GetChuoiKetNoi()))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand();
                    cmd.Connection = conn;
                    cmd.CommandText = "getUsername";
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;

                    DbParameter param = cmd.CreateParameter();
                    param.ParameterName = "@username";
                    param.Value = username;
                    param.DbType = DbType.String;
                    cmd.Parameters.Add(param);

                    cmd.ExecuteNonQuery();
                    ok = true;
                    conn.Close();
                };

            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi: " + ex.Message, "Thông báo lỗi");
                ok = false;
            }
            return ok;
        }

        public static bool laypassword(string password)
        {
            bool ok = false;
            try
            {
                using (SqlConnection conn = new SqlConnection(QUANLYNHASACH.connect.GetChuoiKetNoi()))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand();
                    cmd.Connection = conn;
                    cmd.CommandText = "getPassword";
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;

                    DbParameter param = cmd.CreateParameter();
                    param.ParameterName = "@password";
                    param.Value = password;
                    param.DbType = DbType.String;
                    cmd.Parameters.Add(param);

                    cmd.ExecuteNonQuery();
                    ok = true;
                    conn.Close();
                };

            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi: " + ex.Message, "Thông báo lỗi");
                ok = false;
            }
            return ok;
        }
    }
}
